package org.callcenterkata.dao;

import java.util.ArrayList;
import java.util.List;

public class ToolSearchDao implements IToolSearchDao {

	@Override
	public List<Tool> findToolsByName(String name) {
		List<Tool> tools = Database.INSTANCE.getTools();
		ArrayList<Tool> resultingTools = new ArrayList<Tool>();

		for (Tool tool : tools) {
			if (tool.getName().equals(name)) {
				resultingTools.add(tool);
			}
		}
		return resultingTools;
	}

	@Override
	public List<Tool> findToolsByNickname(String nickname) {
		List<Tool> tools = Database.INSTANCE.getTools();
		ArrayList<Tool> resultingTools = new ArrayList<Tool>();

		for (Tool tool : tools) {
			if (tool.getNickname().equals(nickname)) {
				resultingTools.add(tool);
			}
		}
		return resultingTools;
	}

	// TODO consider using BeanUtils to reduce duplication. Aug 2009
}
